<template>
    <div>
<!--        <table>-->
<!--            <thead>-->
<!--            <tr>-->
<!--                <th colspan="2">-->
<!--                    后台管理系统-->
<!--                </th>-->
<!--            </tr>-->
<!--            </thead>-->
<!--            <tbody>-->
<!--            <tr>-->
<!--                <td class="nav">-->
<!--                    <router-link to="/Users">用户管理</router-link><br/>-->
<!--                    <router-link to="/role">权限管理</router-link><br/>-->
<!--                </td>-->
<!--                <td>-->
<!--                    <router-view></router-view>-->
<!--                </td>-->
<!--            </tr>-->
<!--            </tbody>-->
<!--        </table>-->
        <el-container>
            <el-header>
                <el-row>
                    <el-col :span="22"><el-header><h2>后台管理系统</h2></el-header></el-col>
                    <el-col :span="1"><el-button type="text" @click="logOut" style="color: red; font-size: 20px ;margin-top: 20px" >退出</el-button></el-col>
                 </el-row>
            </el-header>
            <el-container>
                <el-aside width="200px">

                    <el-menu
                            v-for="oneMenu in menuData"
                            :key="oneMenu.mid"
                            default-active="1"
                            class="el-menu-vertical-demo"
                            background-color="#545c64"
                            text-color="#fff"
                            active-text-color="#ffd04b"
                            :default-openeds="defaultOpends"
                            router
                    >
                        <el-submenu :index="oneMenu.mid+''">
                            <template slot="title">
                                <i class="el-icon-location"></i>
                                <span>{{oneMenu.mname}}</span>
                            </template>
                            <el-menu-item-group>
                                <el-menu-item v-for="twoMenu in oneMenu.children" :key="twoMenu.mid" :index="twoMenu.path">
                                    {{twoMenu.mname}}</el-menu-item>
                            </el-menu-item-group>
                        </el-submenu>

                    </el-menu>

                </el-aside>
                <el-main><router-view></router-view></el-main>
            </el-container>
        </el-container>
    </div>
</template>

<script>
    export default {
        name: "Index",
        data(){
          return{
              menuData:[],
              defaultOpends:[]
          }
        },
        created() {
            this.$http.post("toIndex").then(res=>{
                console.info("能操作的菜单",res)
                this.menuData=res.data;
                //默认打开的导航栏（第一项）
                this.defaultOpends=[this.menuData[0].mid+""]
            })
        },
        methods:{
            logOut(){
                    this.$http.post("logOutSuccess").then(res=>{
                        if (res.data.success){
                            this.$router.push("/")
                        }
                    })
            }
        }
    }
</script>

<style scoped>
    /* table{*/
    /*     width: 100%;*/
    /*     border: 1px solid black;*/
    /*     border-collapse: collapse;*/
    /* }*/
    /*th,td{*/
    /*    border: 1px solid black;*/
    /*}*/
    /*.nav{*/
    /*    width: 200px;*/
    /*    height: 400px;*/
    /*    vertical-align: top;*/
    /*    text-align: center;*/
    /*}*/
    *{
        padding: 0px;
        margin: 0px;
    }
    .el-header, .el-footer {
        background-color: #B3C0D1;
        color: #333;
    }

    .el-aside {
        background-color: #D3DCE6;
        color: #333;
        /*text-align: center;*/
        height: 822px;
    }

    .el-main {
        color: #333;
        /*text-align: center;*/
        /*line-height: 160px;*/
    }

    body > .el-container {
        margin-bottom: 40px;
    }

    .el-container:nth-child(5) .el-aside,
    .el-container:nth-child(6) .el-aside {
        line-height: 260px;
    }

    .el-container:nth-child(7) .el-aside {
        line-height: 320px;
    }
</style>